package org.jobtask.ui;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.border.TitledBorder;

import org.jobtask.config.ResourceMessages;

public class TaskListPanel extends JPanel{
	
	
	private static final long serialVersionUID = -6871878051626462313L;

	public TaskListPanel(CommonComponents comp){
		this.initPanel(comp);
	}

	private void initPanel(CommonComponents comp){
		this.setLayout(new BorderLayout());
		
		/**
		 * 放置添加和移除任务的按钮
		 */
		JPanel topPanel=new JPanel();
		topPanel.add(comp.getAddTaskBut());
		topPanel.add(comp.getDelTaskBut());
		
		
		JScrollPane listGroupPanel=new JScrollPane(comp.getTaskGroupList());
		JPanel addGroupPanel=new JPanel(new BorderLayout());
		addGroupPanel.add(comp.getAddGoupBut(),BorderLayout.PAGE_START);
		addGroupPanel.add(listGroupPanel);
		addGroupPanel.add(comp.getDelGoupBut(),BorderLayout.PAGE_END);
		
		//添加任务列表
		JScrollPane listPanel=new JScrollPane(comp.getTaskList());
		
		JPanel groupPanel=new JPanel(new BorderLayout());
		TitledBorder textTitleBorder=BorderFactory.createTitledBorder(ResourceMessages.getString("CommonComp.12"));
		textTitleBorder.setTitleColor(new Color(104,156,226));
		textTitleBorder.setBorder(BorderFactory.createLineBorder(new Color(68,68,68)));
		groupPanel.setBorder(textTitleBorder);
		groupPanel.add(addGroupPanel,BorderLayout.LINE_START);
		groupPanel.add(listPanel);
		
		//添加属性表
		JScrollPane tablePanel=new JScrollPane(comp.getInfoTable());
		
		JSplitPane splitPane=new JSplitPane(JSplitPane.VERTICAL_SPLIT);
		splitPane.setDividerLocation(380);
		splitPane.setDividerSize(5);
		splitPane.setOneTouchExpandable(true);
		splitPane.setTopComponent(groupPanel);
		splitPane.setBottomComponent(tablePanel);
		
		this.add(topPanel,BorderLayout.PAGE_START);
		this.add(splitPane,BorderLayout.CENTER);
	}
}
